Lab
Tools for converting RGB colors to L*a*b* measurements.
RGB colors, for this crate at least, are considered to be composed of u8
values from 0 to 255, while L*a*b* colors are represented by its own struct
that uses f32
values.
Usage
Converting single values
To convert a single value, use one of the functions
lab::Lab::from_rgb(rgb: &[u8; 3]) -> Lab
lab::Lab::from_rgba(rgba: &[u8; 4]) -> Lab
(drops the fourth alpha byte)lab::Lab::to_rgb(&self) -> [u8; 3]
extern crate lab;
use Lab;
let pink_in_lab = from_rgb;
// Lab { l: 66.639084, a: 52.251457, b: 14.860654 }
Converting multiple values
To convert slices of values
lab::rgbs_to_labs(rgbs: &[[u8; 3]]) -> Vec<Lab>
lab::labs_to_rgbs(labs: &[Lab]) -> Vec<[u8; 3]>
lab::rgb_bytes_to_labs(bytes: &[u8]) -> Vec<Lab>
lab::labs_to_rgb_bytes(labs: &[Lab]) -> Vec<u8>
extern crate lab;
use rgbs_to_labs;
let rgbs = vec!;
let labs = rgbs_to_labs;
extern crate lab;
use rgb_bytes_to_labs;
let rgbs = vec!;
let labs = rgb_bytes_to_labs;
These functions will use x86_64 AVX2 instructions if compiled to a supported target.
Minimum Rust version
Lab 0.8.0 requires Rust >= 1.36.0 for the MaybeUninit struct
Lab 0.7.0 requires Rust >= 1.31.0 for the chunks_exact slice method